import WMap from '../map/index.js'

const map = new WMap.Map('map', {
	center: new WMap.LngLat(116.479662,39.996956),
  zoom: 15
})
map.on('click', e => {
	console.log(e.lngLat)
})

let tools = new WMap.Tool(map)
let tool = document.querySelector('#tool')
tool.onchange = () => {
  switch (tool.value) {
    case '':
      tools.close()
      break
    case 'distance':
      tools.distance()
      break
    case 'area':
      tools.area()
      break
  }
}

tools.on('done', e => {
  console.log(e)
})

let location = document.querySelector('#location')
let lon = document.querySelector('#lon')
let lat = document.querySelector('#lat')
location.onclick = () =>{
  const m1 = new WMap.Marker({
    icon: 'img/marker_red.png',
    position: [lon.value, lat.value]
  })
	map.add(m1)
const lngLat = new WMap.LngLat(lon.value, lat.value)

map.setCenter(lngLat,18);
}
